home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / asm_subr.arc / BIN8OUT < prev    next >
Encoding:
Text File  |  1985-12-22  |  1.3 KB  |  40 lines

  1. ;-------------------------bin8out routine begins--------------------------+
  2. ; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.
  3. ;         page : 43
  4. ;
  5. ; ROUTINE FOR CONVERSION FROM 8-BIT BINARY TO ASCII BINARY
  6. ;
  7. ; FUNCTION: This routine accepts an 8-bit binary number in the DL register
  8. ; and converts it to ASCII binary form which is sent to the std output
  9. ; device.
  10. ; INPUT: Upon entry an 8-bit binary is in the DL register
  11. ; OUTPUT: A string of ASCII digits representing a binary number is sent
  12. ; out through the std output device.
  13. ; REGISTERS USED:  No registers are modified.  DL is used for input
  14. ; SEGMENTS REFERENCED:  None
  15. ; ROUTINES CALLED:  STDOUT
  16. ; SPECIAL NOTES: None
  17. ;
  18. ; ROUTINE TO CONVERT FROM INTERNAL 8-BIT BINARY TO ASCII BINARY
  19. ;
  20. bin8out    proc    far
  21. ;
  22.     push    cx        ; save registers
  23.     push    ax
  24. ;
  25.     mov    cx,8        ; loop for a count of 8
  26. bin8out1:
  27.     rol    dl,1        ; rotate DL left once
  28.     mov    al,dl        ; move into AL
  29.     and    al,1        ; just keep digit
  30.     add    al,30h        ; adjust AL to ASCII
  31.     call    stdout        ; output to console
  32.     loop    bin8out1    ; again until cx is 0
  33. ;
  34.     pop    ax        ; restore registers
  35.     pop    cx
  36.     ret            ; return
  37. ;
  38. bin8out    endp
  39. ;-------------------------bin8out routine ends---------------------------+
  40.